<template>
  <div>
    <transition
      name="custom-classes-transition"
      enter-active-class="animated fadeInUp"
      leave-active-class="animated fadeOutDown"
    >
      <PlayBar
        v-if="currentSong && showPlayBar"
        :currentSong="currentSong"
        :playing="playing"
        :currentTime="currentTime"
        :duration="duration"
        @audio-play-handler="$emit('audio-play-handler')"
        @audio-pause-handler="$emit('audio-pause-handler')"
        @click.native="showPlayBar = false"
      />
    </transition>
    <transition
      name="custom-classes-transition"
      enter-active-class="animated fadeIn"
      leave-active-class="animated fadeOut"
    >
      <PlayPage
        v-if="currentSong && !showPlayBar"
        @hide-play-page="showPlayBar = true"
        :currentSong="currentSong"
        :playing="playing"
        :currentTime="currentTime"
        :duration="duration"
        @update:currentTime="$emit('update:currentTime', $event)"
        @audio-play-handler="$emit('audio-play-handler')"
        @audio-pause-handler="$emit('audio-pause-handler')"
        :currentPLayList="currentPLayList"
        @update:currentSong="$emit('update:currentSong', $event)"
        @prev-song="$emit('prev-song')"
        @next-song="$emit('next-song')"
      />
    </transition>

    <MyPlayList
      v-if="showMyPlayList"
      :currentPLayList="currentPLayList"
      @update:currentSong="$emit('update:currentSong', $event)"
      :currentSong="currentSong"
    />
  </div>
</template>

<script>
import PlayBar from "@/components/PlayBar.vue";
import PlayPage from "@/components/PlayPage.vue";
import MyPlayList from "@/components/MyPlayList.vue";

export default {
  components: {
    PlayBar,
    PlayPage,
    MyPlayList,
  },
  props: {
    currentSong: Object,
    playing: Boolean,
    currentTime: Number,
    duration: Number,
    currentPLayList: Array,
  },
  data: function () {
    return {
      showPlayBar: true,
      showMyPlayList: false,
    };
  },
};
</script>

<style>
</style>